﻿using Windows.Storage.Streams;

namespace JustinAngel.MindwaveSensor.WP8.Common
{
    public static class BufferExtensions
    {
        public static byte[] GetBytesFromBuffer(this IBuffer buffer)
        {
            using (var dr = DataReader.FromBuffer(buffer))
            {
                var bytes = new byte[dr.UnconsumedBufferLength];
                dr.ReadBytes(bytes);
                return bytes;
            }
        }
    }
}
